package com.wjf.concurrency.example.singleton;

import com.wjf.concurrency.annoations.ThreadSafe;

/*
* 饿汉模式
* 单例实例在类装载时进行创建
* */
@ThreadSafe
public class SingletonExample6 {

    //私有的构造函数
    private SingletonExample6(){

    }
    //单例对象
    public static SingletonExample6 intance=null;
    static {
        intance=new SingletonExample6();
    }



    //静态的工厂方法
    public static SingletonExample6 getInstance(){
        return intance;
    }

    public static void main(String[] args) {
        System.out.println(getInstance());
        System.out.println(getInstance());
    }
}
